package com.guanyong.webapi.controllers.api;

import com.guanyong.model.FilmModel;
import com.guanyong.model.VideoTypeModel;
import com.guanyong.utils.Cache.ICahce.ICache;
import com.guanyong.utils.Comm.ResultObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/10/11 0011.
 */
@RestController
@RequestMapping("/api/demo/")
public class DemoApi {

    @Autowired
    ICache cache;

    @Value("${video.type.cache}")
    String videoTypeCache;


    @RequestMapping(value = "demo", method = RequestMethod.GET)
    public ResultObject<List<String>> demo(
            @RequestParam String typeList){
        ResultObject<List<String>> resultObject=new ResultObject<List<String>>();
        String[] strLsit =typeList.split(",");
        List<String> lsit = new ArrayList<String>();
        for (String str:strLsit ){
            lsit.add(cache.get(videoTypeCache,str).toString());
        }
        Map<String,Object> map =cache.get(videoTypeCache);
        for (Map.Entry<String, Object> entry : map.entrySet()) {
            System.out.println("key= " + entry.getKey() + " and value= " + entry.getValue());
        }
        resultObject.setResult(lsit);
        return  resultObject;
    }
}
